<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
<!--      <el-form-item label="申请人姓名" prop="applyName" label-width="20">-->
<!--        <el-input-->
<!--          v-model="queryParams.applyName"-->
<!--          placeholder="请输入申请人姓名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <el-form-item label="成果名称" prop="resultName">
        <el-input
          v-model="queryParams.resultName"
          placeholder="请输入成果名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成果类别" prop="resultCategory">
        <el-input
          v-model="queryParams.resultCategory"
          placeholder="请输入成果类别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="公司名称" prop="enterpriseName">-->
<!--        <el-input-->
<!--          v-model="queryParams.enterpriseName"-->
<!--          placeholder="请输入公司名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="完成单位" prop="completionUnit">-->
<!--        <el-input-->
<!--          v-model="queryParams.completionUnit"-->
<!--          placeholder="请输入完成单位"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      <el-form-item label="成果情况" prop="resultIntroduction">-->
<!--        <el-input-->
<!--          v-model="queryParams.resultIntroduction"-->
<!--          placeholder="请输入成果情况"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="成果来源" prop="resultSource">
        <el-select
          v-model="queryParams.resultSource"
          placeholder="请选择成果来源"
          clearable
        >
          <el-option
            v-for="dict in dict.type.cxcy_result_source"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="负责人姓名" prop="firstName">
        <el-input
          v-model="queryParams.firstName"
          placeholder="请输入负责人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人电话" prop="firstNumber">
        <el-input
          v-model="queryParams.firstNumber"
          placeholder="请输入负责人电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核状态" prop="auditState">
        <el-select
          v-model="queryParams.auditState"
          placeholder="请选择审核状态"
          clearable
        >
          <el-option
            v-for="dict in dict.type.cxcy_audit_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <div style="text-align: right;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['project:lystransformation:export']">导出</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </div>
<br>


    </el-form>

<!--    <el-row :gutter="10" class="mb8">-->
<!--      <el-col :span="1.5">-->
<!--&lt;!&ndash;        <el-button&ndash;&gt;-->
<!--&lt;!&ndash;          type="primary"&ndash;&gt;-->
<!--&lt;!&ndash;          plain&ndash;&gt;-->
<!--&lt;!&ndash;          icon="el-icon-plus"&ndash;&gt;-->
<!--&lt;!&ndash;          size="mini"&ndash;&gt;-->
<!--&lt;!&ndash;          @click="wordxia"&ndash;&gt;-->
<!--&lt;!&ndash;          v-hasPermi="['project:lystransformation:xiazai']"&ndash;&gt;-->
<!--&lt;!&ndash;        >下载模板</el-button>&ndash;&gt;-->
<!--&lt;!&ndash;        <el-button&ndash;&gt;-->
<!--&lt;!&ndash;          type="success"&ndash;&gt;-->
<!--&lt;!&ndash;          plain&ndash;&gt;-->
<!--&lt;!&ndash;          icon="el-icon-edit"&ndash;&gt;-->
<!--&lt;!&ndash;          size="mini"&ndash;&gt;-->
<!--&lt;!&ndash;          :disabled="single"&ndash;&gt;-->
<!--&lt;!&ndash;          @click="handleUpdate"&ndash;&gt;-->
<!--&lt;!&ndash;          v-hasPermi="['project:lystransformation:edit']"&ndash;&gt;-->
<!--&lt;!&ndash;        >修改</el-button>&ndash;&gt;-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['project:lystransformation:remove']"-->
<!--        >删除</el-button>-->
<!--        <el-col :span="1.5">-->
<!--          <el-button-->
<!--            type="warning"-->
<!--            plain-->
<!--            icon="el-icon-download"-->
<!--            size="mini"-->
<!--            @click="handleExport"-->
<!--            v-hasPermi="['project:lystransformation:export']"-->
<!--          >导出</el-button>-->
<!--        </el-col>-->
<!--      </el-col>-->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>


    <el-table v-loading="loading" :data="transformationList" border @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" :index="indexMethod" type="index"  />
<!--      <el-table-column label="ID" align="center" prop="id" />-->
<!--      <el-table-column label="申请人姓名" align="center" prop="applyName" />-->
<!--      <el-table-column label="申请人学号" align="center" prop="applyNumber" />-->
<!--      <el-table-column label="申请时间" align="center" prop="applyTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="成果名称" align="center" prop="resultName" />
      <el-table-column label="成果类别" align="center" prop="resultCategory" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cxcy_result_category" :value="scope.row.resultCategory"/>
        </template>
      </el-table-column>
<!--      <el-table-column label="成果情况" align="center" prop="resultIntroduction" />-->
      <el-table-column label="完成单位" align="center" prop="completionUnit" />
      <el-table-column label="成果来源" align="center" prop="resultSource" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cxcy_result_source" :value="scope.row.resultSource"/>
        </template>

      </el-table-column>
      <el-table-column label="成果背景" align="center" prop="resultBackground" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.cxcy_result_background" :value="scope.row.resultBackground"/>
        </template>
      </el-table-column>
      <el-table-column label="负责人姓名" align="center" prop="firstName" />
      <el-table-column label="负责人电话" align="center" prop="firstPhone" />
      <el-table-column label="审核状态" align="center" prop="auditState" >
      <template slot-scope="scope">
        <span v-if="scope.row.auditState==0">待上传</span>
        <span v-if="scope.row.auditState==1">待审核</span>
        <span v-if="scope.row.auditState==2">审核通过</span>
        <span v-if="scope.row.auditState==3">审核不通过</span>
      </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-show="scope.row.signingStatus=='1'&&(scope.row.numberYears==null||scope.row.numberYears=='')"
            size="mini"
            type="text"
            icon="el-icon-plus"
            @click="zhuanhua(scope.row)"
            v-hasPermi="['project:lystransformation:query']"
          >成果转化信息填写</el-button>


          <el-button
            v-show="scope.row.numberYears!=null&&scope.row.numberYears!=''"
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="wordxia(scope.row)"
            v-hasPermi="['project:lystransformation:edit']"
          >1.成果审批表下载</el-button>
          <el-button
            v-show="scope.row.numberYears!=null&&scope.row.numberYears!=''"
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="wordxia2(scope.row)"
            v-hasPermi="['project:lystransformation:xiazai']"
          >2.协议表及承诺涵下载</el-button>
          <el-button
            v-show="scope.row.numberYears!=null&&scope.row.numberYears!=''"
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="wordxia3(scope.row)"
            v-hasPermi="['project:lystransformation:xiazai']"
          >3.专利/软著证书下载</el-button>

<!--          note1签约状态-->
            <el-button
              v-show="(scope.row.templatePath==null||scope.row.templatePath=='')&&(scope.row.numberYears!=null&&scope.row.numberYears!='')"
              size="mini"
              type="text"
              icon="el-icon-upload2"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['project:lystransformation:edit']"
            >成果转化文件上传</el-button>
          <el-button
            v-show="scope.row.auditState=='2'"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['project:lystransformation:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['project:lystransformation:remove']"
          >删除</el-button>
          <el-button
            v-show="scope.row.auditState=='1'"
            size="mini"
            type="text"
            icon="el-icon-zoom-in"
            @click="handleView(scope.row,scope.index)"
            v-hasPermi="['project:lystransformation:revise']"
          >审核</el-button>
<!--          <el-button-->
<!--            v-show="scope.row.fileId!=null"-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            @click="handleDetail(scope.row,scope.index)"-->
<!--            v-hasPermi="['project:lystransformation:query']"-->
<!--          >详情</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 审核成果申请对话框 -->
    <el-dialog :title="chief.title" :visible.sync="chief.open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">成果基本信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <!--            <el-row>-->
            <!--              <el-col :span="12">-->
            <!--                <el-form-item label="申请人姓名" prop="applyName">-->
            <!--                  <el-input v-model="form.applyName"  readonly="true"/>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--              <el-col :span="12">-->
            <!--                <el-form-item label="申请人学号" prop="applyNumber">-->
            <!--                  <el-input v-model="form.applyNumber"  readonly="true"/>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <!--            </el-row>-->
            <!--            <el-row>-->
            <!--              <el-col :span="12">-->
            <!--                <el-form-item label="申请时间" prop="applyTime">-->
            <!--                  <el-date-picker-->
            <!--                    clearable-->
            <!--                    style="width: 100%"-->
            <!--                    v-model="form.applyTime"-->
            <!--                    type="date"-->
            <!--                    readonly="true"-->
            <!--                    value-format="yyyy-MM-dd"-->
            <!--                    placeholder="请选择时间">-->
            <!--                  </el-date-picker>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->

            <el-row>
<!--              <el-row>-->

<!--                <el-form-item label="成果转化材料下载" prop="note10">-->
<!--                  <el-button-->
<!--                    type="primary"-->
<!--                    plain-->

<!--                    size="mini"-->
<!--                    @click="wordxia1"-->
<!--                    v-hasPermi="['project:lystransformation:xiazai3']"-->
<!--                  >材料下载</el-button>-->

<!--                </el-form-item>-->

<!--              </el-row>-->


              <!--              <el-col :span="12">-->
              <!--                <el-form-item label="审核时间" prop="auditTime">-->
              <!--                  <el-date-picker-->
              <!--                    clearable-->
              <!--                    style="width: 100%"-->
              <!--                    v-model="form.auditTime"-->
              <!--                    type="date"-->
              <!--                    readonly="true"-->
              <!--                    value-format="yyyy-MM-dd"-->
              <!--                    placeholder="请选择时间">-->
              <!--                  </el-date-picker>-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->


              <!--              <el-col :span="12">-->
              <!--                <el-form-item label="审核人工号" prop="auditNumber">-->
              <!--                  <el-input v-model="form.auditNumber"  />-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
              <!--</el-row>-->

              <!--            <el-row>-->
              <!--              <el-col :span="12">-->
              <!--                <el-form-item label="审核人姓名" prop="auditName">-->
              <!--                  <el-input v-model="form.auditName"  />-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->


              <el-col :span="12"  >
                <el-form-item label="成果名称" prop="resultName" >
                  <el-col   >

                                     <el-input v-model="form.resultName" disabled />
                  </el-col>
                                    </el-form-item>
              </el-col>
              <el-col :span="12"  >
                <el-form-item label="申请人姓名" prop="applyName" >
                  <el-col   >

                    <el-input v-model="form.applyName" disabled />
                  </el-col>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12"  >
                <el-form-item label="申请人学号" prop="applyNumber" >
                  <el-col   >

                    <el-input v-model="form.applyNumber"  disabled  />
                  </el-col>
                </el-form-item>
              </el-col>
              <el-col :span="12"  >
                <el-form-item label="申请时间" prop="applyTime" >
                  <el-col   >

                    <el-input v-model="form.applyTime" disabled />
                  </el-col>
                </el-form-item>
              </el-col>
            </el-row>

          </el-main>
        </el-container>
                            <el-container>
                              <el-header>
                                <el-divider content-position="left">
                                  <p style="color: #00afff; font-size: 20px;">审核成果基本信息</p>
                                </el-divider>
                              </el-header>
                              <el-main>
                    <!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="申请人姓名" prop="applyName">-->
<!--                  <el-input v-model="form.applyName"  readonly="true"/>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="申请人学号" prop="applyNumber">-->
<!--                  <el-input v-model="form.applyNumber"  readonly="true"/>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="申请时间" prop="applyTime">-->
<!--                  <el-date-picker-->
<!--                    clearable-->
<!--                    style="width: 100%"-->
<!--                    v-model="form.applyTime"-->
<!--                    type="date"-->
<!--                    readonly="true"-->
<!--                    value-format="yyyy-MM-dd"-->
<!--                    placeholder="请选择时间">-->
<!--                  </el-date-picker>-->
<!--                </el-form-item>-->
<!--              </el-col>-->

<el-row>
  <el-row>

      <el-form-item label="成果转化材料下载" prop="note10">
        <el-button
          type="primary"
          plain

          size="mini"
          @click="wordxia1"
          v-hasPermi="['project:lystransformation:xiazai3']"
        >材料下载</el-button>

      </el-form-item>

  </el-row>


<!--              <el-col :span="12">-->
<!--                <el-form-item label="审核时间" prop="auditTime">-->
<!--                  <el-date-picker-->
<!--                    clearable-->
<!--                    style="width: 100%"-->
<!--                    v-model="form.auditTime"-->
<!--                    type="date"-->
<!--                    readonly="true"-->
<!--                    value-format="yyyy-MM-dd"-->
<!--                    placeholder="请选择时间">-->
<!--                  </el-date-picker>-->
<!--                </el-form-item>-->
<!--              </el-col>-->


<!--              <el-col :span="12">-->
<!--                <el-form-item label="审核人工号" prop="auditNumber">-->
<!--                  <el-input v-model="form.auditNumber"  />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--</el-row>-->

<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="审核人姓名" prop="auditName">-->
<!--                  <el-input v-model="form.auditName"  />-->
<!--                </el-form-item>-->
<!--              </el-col>-->


              <el-col :span="12"  >
                <el-form-item label="审核状态" prop="auditState" >
                  <el-select v-model="form.auditState"  style="width: 100%;"   placeholder="请选择审核结果" >
                    <el-option
                      v-for="item in auditState"
                      :key="item.value"
                      :label="item.label"

                      :value="item.value"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>

            </el-row>
                                <el-row>
                                  <el-form-item label="备注" prop="note3">
                                    <el-input v-model="form.note3" type="textarea" placeholder="请输入备注" />
                                  </el-form-item>
                                </el-row>
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="chiefForm">确 定</el-button>
        <el-button @click="chiefCancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改成果转化申请对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff; font-size: 20px;">成果转化</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-row>
              <el-form-item label="成果转化材料上传" prop="note10">

                <file-upload v-model="form.templatePath"></file-upload>
                <span style="color: blue">选取文件后可点击框内文件查看自己上传的文件<br></span>
                <span style="color: red">压缩包必须包含三项材料：1.成果审批表2.收益分配表及承诺函3.专利或软著登记证书复印件或技术秘密说明书<br></span>
              </el-form-item>

            </el-row>
<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="拟交易价格" prop="transactionPrice">-->
<!--                  <el-input v-model="form.transactionPrice"  />-->
<!--                </el-form-item>-->
<!--              </el-col>-->


<!--              <el-col :span="12">-->
<!--                <el-form-item label="付款安排" prop="payArrangement">-->
<!--                  <el-input v-model="form.payArrangement" type="textarea" />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="发明人承诺内容" prop="commitmentContent">-->
<!--                  <el-input v-model="form.commitmentContent" type="textarea"  />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="发明人承诺时间" prop="commitmentTime">-->
<!--                  <el-date-picker-->
<!--                    clearable-->
<!--                    style="width: 100%"-->
<!--                    v-model="form.commitmentTime"-->
<!--                    type="date"-->

<!--                    value-format="yyyy-MM-dd"-->
<!--                    placeholder="请选择时间">-->
<!--                  </el-date-picker>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--            <el-row>-->

<!--              <el-col :span="12"  >-->
<!--                <el-form-item label="发明人承诺电话" prop="commitmentPhone">-->
<!--                  <el-input v-model="form.commitmentPhone"  />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--              <el-col :span="12"  >-->
<!--                <el-form-item label="主管学院意见内容" prop="opinionContent">-->
<!--                  <el-input v-model="form.opinionContent"  type="textarea" />-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
<!--            <el-row>-->
<!--              <el-col :span="12">-->
<!--                <el-form-item label="主管学院意见时间" prop="opinionTime">-->
<!--                  <el-date-picker-->
<!--                    clearable-->
<!--                    style="width: 100%"-->
<!--                    v-model="form.opinionTime"-->
<!--                    type="date"-->

<!--                    value-format="yyyy-MM-dd"-->
<!--                    placeholder="请选择时间">-->
<!--                  </el-date-picker>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
<!--            </el-row>-->
          </el-main>
        </el-container>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listTransformation, getTransformation, delTransformation, addTransformation, updateTransformation,getshenhe,updateTransformation1 } from "@/api/module/lys/transformation";

export default {
  name: "Transformation",
  dicts:['cxcy_result_category','cxcy_result_source','cxcy_result_background','cxcy_audit_status'],
  data() {
    return {
      user: '',
      // 以下websocket
      wsIsRun: false,
      // 定义ws对象
      webSocket: null,
      // ws连接次数
      wsNumber: 0,
      // ws请求链接（类似于ws后台地址）
      ws: '',
      // ws定时器
      wsTimer: null,
      // 以上websocket
      unreadMsgNums: 0,
      unreadMsgNumsShow: '',
      hasConnected: false,
      auditState:[{
        value: '2',
        label: '通过'
      }, {
        value: '3',
        label: '不通过'
      }],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 成果转化申请表格数据
      transformationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        acceptTime: null,
        fileId: null,
        transactionPrice: null,
        payArrangement: null,
        commitmentContent: null,
        commitmentTime: null,
        commitmentPhone: null,
        opinionContent: null,
        opinionTime: null,
        applyName: null,
        applyNumber: null,
        applyTime: null,
        auditState: null,
        auditTime: null,
        auditName: null,
        auditNumber: null,
        resultId: null,
        resultName: null,
        resultCategory: null,
        resultIntroduction: null,
        completionUnit: null,
        firstName: null,
        firstCollege: null,
        firstMajor: null,
        firstNumber: null,
        firstPhone: null,
        firstIdnumber: null,
        secondName: null,
        secondCollege: null,
        secondMajor: null,
        secondNumber: null,
        secondPhone: null,
        secondIdnumber: null,
        thirdName: null,
        thirdCollege: null,
        thirdMajor: null,
        thirdNumber: null,
        thirdPhone: null,
        thirdIdnumber: null,
        fourthName: null,
        fourthCollege: null,
        fourthMajor: null,
        fourthNumber: null,
        fourthPhone: null,
        fourthIdnumber: null,
        fifthName: null,
        fifthCollege: null,
        fifthMajor: null,
        fifthNumber: null,
        fifthPhone: null,
        fifthIdnumber: null,
        enterpriseNumber: null,
        enterpriseName: null,
        corporateName: null,
        corporatePhone: null,
        corporateNumber: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null,
        orderByColumn: "auditState",
        isAsc: "asc"
      },
      // 表单参数
      form: {

      },
      // 表单校验
      rules: {
        acceptTime: [
          { required: true, message: "受理时间不能为空", trigger: "blur" },
        ],
        fileId: [
          { required: true, message: "档案编号不能为空", trigger: "blur" },
        ],
        transactionPrice: [
          { required: true, message: "拟交易价格不能为空", trigger: "blur" },
        ],
        payArrangement: [
          { required: true, message: "付款安排不能为空", trigger: "blur" },
        ],
        commitmentContent: [
          { required: true, message: "发明人承诺内容不能为空", trigger: "blur" },
        ],
        commitmentTime: [
          { required: true, message: "发明人承诺时间不能为空", trigger: "blur" },
        ],
        commitmentPhone: [
          { required: true, message: "发明人承诺电话不能为空", trigger: "blur" },
        ],
        opinionContent: [
          { required: true, message: "主管学院意见内容不能为空", trigger: "blur" },
        ],
        templatePath: [
          { required: true, message: "上传文件不能为空", trigger: "blur" },
        ],
      },
      chief:{

        // 是否显示弹出层（用户查询）
        open: false,
        // 弹出层标题（用户查询）
        title: "成果审核",

      },
    };
  },
  created() {
    this.wsIsRun = true
    this.wsNumber = 1
    this.wsInit();
    this.initData()
    this.getList();

  },
  activated() {
    this.initData()
  },
  methods: {
    /**
     * start
     * 初始化ws
     */
    wsInit() {
      // console.log("userName: " + this.$store.state.user.ipp)
      console.log("user: " + this.$store.state.constip.ipp)
      // const wsuri = 'ws://' + '210.47.178.218' + ':8080/library/wsService/' + this.$store.state.user.name
      this.getConfigKey("sys.account.ip").then(response => {
        this.sysipp = response.msg;
      });
      console.log("sysipp: " + this.sysipp)
      const wsuri = 'ws://' + this.sysipp + '/library/wsService/' +
        this.$store.state.constip.ipp + "_" + Math.floor(Math.random() * (99999 - 10000) + 10000);
      console.log("wsuri: " + wsuri)
      this.ws = wsuri
      if (!this.wsIsRun)
        return
      // 销毁ws
      this.wsDestroy()
      // 初始化ws
      this.webSocket = new WebSocket(this.ws)
      // ws连接建立时触发

      this.webSocket.addEventListener('open', this.wsOpenHanler)
      // ws服务端给客户端推送消息

      this.webSocket.addEventListener('message', this.wsMessageHanler)

      // ws通信发生错误时触发
      this.webSocket.addEventListener('error', this.wsErrorHanler)
      // ws关闭时触发

      this.webSocket.addEventListener('close', this.wsCloseHanler)

      clearInterval(this.wsTimer);
    },
    subSend(userId) {

      //获取msg的value
      // var msg = document.getElementById("msg").value;

      this.webSocket.send(userId);

      // ws服务端给客户端推送消息

      // document.getElementById("msg").value="";
    },


    wsOpenHanler(event) {
      console.log('ws建立连接成功')
    },
    wsMessageHanler(e) {

      //Cookies.set('unreadNums', '6')

      this.openMsg(e)
      //const redata = JSON.parse(e.data)
      //console.log(redata)

    },
    /**
     * ws通信发生错误
     */
    wsErrorHanler(event) {
      console.log(event, '通信发生错误')
      console.log("第" + this.wsNumber + "次断线重连(5次未连接将自动断开)")
      this.wsNumber++
      if (this.wsNumber < 6) this.wsInit();
      //this.wsInit()
    },
    /**
     * ws关闭
     */
    wsCloseHanler(event) {
      console.log(event, 'ws关闭')
      console.log("websocket连接超时，已自动断开")
      //this.wsInit()
    },
    /**
     * 销毁ws
     */
    wsDestroy() {
      console.log("hello world")
      if (this.webSocket !== null) {
        this.webSocket.removeEventListener('open', this.wsOpenHanler)
        this.webSocket.removeEventListener('message', this.wsMessageHanler)
        this.webSocket.removeEventListener('error', this.wsErrorHanler)
        this.webSocket.removeEventListener('close', this.wsCloseHanler)
        this.webSocket.close()
        this.webSocket = null
        clearInterval(this.wsTimer)
        console.log("zoul111")
      } else {
        console.log("zoul")
      }
    },
    /**
     * 弹窗
     */
    openMsg(e) {
      const h = this.$createElement;
      if (e.data) {
        console.log(e.data+"222")
        if(e.data==1) {
          this.$router.push({path: "/dashujuzhanshi/dashujushouye"})
        }
        else if(e.data==2){
          this.$router.push({path: "/shou"})
        }else if(e.data==3){
          this.$router.push({path: "/mwnhugongshi"})
        }else if(e.data==4){
          this.$router.push({path: "/liucheng"})
        }else if(e.data==5){
          this.$router.push({path: "/dashujuzhanshi/xueyuan"})
        }else if(e.data==6){
          this.$router.push({path: "/dashujuzhanshi/nianfen"})
        }else if(e.data==10){
          window.scrollBy(0, 100);
        }else if(e.data==11){
          window.scrollBy(0, -100);
        }else if(e.data==21){
          this.$router.push({path: "/ykqlogin3"})
        } else if(e.data==22){
          this.$router.push({path: "/ykqlogin4"})
        }else if(e.data==23){
          this.$router.push({path: "/ykqlogin5"})
        }else if(e.data==24){
          this.$router.push({path: "/shou"})
        }else if(e.data==210){
          this.$router.push({path: "/index"})
        }else if(e.data==211){
          this.$router.push({path: "/transformation"})
        }else if(e.data==212){
          this.$router.push({path: "/wodehetong"})
        }else if(e.data==213){
          this.$router.push({path: "/expense"})
        }else if(e.data==214){
          this.$router.push({path: "/qiye"})
        }else if(e.data==215){
          this.$router.push({path: "/geren"})
        }else if(e.data==216){
          this.$router.push({path: "/chengguogongshi"})
        }else if(e.data==217){
          this.$router.push({path: "/daochuxinxi"})
        }else if(e.data==218){
          this.$router.push({path: "/resultapply"})
        }else if(e.data==12){
          this.queryParams.signingStatus="0";
          console.log(this.queryParams.signingStatus)

        }else if(e.data==13){
          this.queryParams.signingStatus="1";
          console.log(this.queryParams.signingStatus)

        }else if(e.data>500&&e.data<2000){
          let id=e.data-500
          this.$router.push({path: "/detail",query: {id}})

        }else if(e.data>2000&&e.data<3000){
          let nianfen=e.data
          this.$router.push({path: "/dashujuzhanshi/xueyuan",query: {nianfen}})

        }else if(e.data>3000&&e.data<4000){
          let firstcollege=e.data
          let i_xueyuan=firstcollege-3000
          let xueyuan = '';
          if(i_xueyuan<10){
            xueyuan='00'+i_xueyuan;
          }else if(i_xueyuan>=10 && i_xueyuan<100){
            xueyuan='0'+i_xueyuan;
          }else{

          }
          console.log(xueyuan)
          this.$router.push({path: "/dashujuzhanshi/nianfen",query: {xueyuan}})
        }
        else{
          let userId=e.data
          this.$router.push({path: "/view",query: {userId}})

        }
        //结束

        /*var dv = document.getElementById("dv");
        dv.innerHTML += e.data + " ";*/
        /*this.$router.push({path: "/"});*/

        var data = JSON.parse(e.data)
        var route = this.$router;
        var msgType = data.msgType;
        /*if (msgType == "push") {
          // 如果是推送的是一条消息
          this.unreadMsgNums++;
          if (this.unreadMsgNums > 99) {
            this.unreadMsgNumsShow = "99+";
          } else {
            this.unreadMsgNumsShow = String(this.unreadMsgNums);
          }

          this.$notify.info({
            title: data.msgTitle,
            message: data.msgContent,
            onClick() {
              console.log(route)
              route.push({path: "/library/yyg/msg/list"});
            }
          });
        } else if (msgType == "unread") {
          // 如果推送的是未读消息数
          //Cookies.set('unreadNums', data.unreadNums);
          this.unreadMsgNums = Number(data.unreadNums);
          if (this.unreadMsgNums > 0) {
            this.unreadMsgNumsShow = String(this.unreadMsgNums);
            if (this.unreadMsgNums > 99) {
              this.unreadMsgNumsShow = "99+";
            }
            this.$notify.info({
              title: "消息提醒",
              //message: data.msgContent,
              message: "您当前有" + this.unreadMsgNumsShow + "条未读消息，点击此处查看",
              onClick() {
                console.log(route)
                route.push({path: "/library/yyg/msg/list"});
              }
            });
          }
        } else if (msgType == "read") {
          // 如果推送的是用户已读消息
          this.unreadMsgNums--;
          if (this.unreadMsgNums > 0 && this.unreadMsgNums <= 99) {
            this.unreadMsgNumsShow = String(this.unreadMsgNums);
          } else if (this.unreadMsgNums <= 0) {
            this.unreadMsgNumsShow = '';
          }
        }
*/
      }
    },
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index;
    },
    initData() {
      // 执行初始化数据的操作
      this.getList();
    },
    zhuanhua(row) {
      this.reset();
    /*  const id = row.resultId*/
      const id = row.id

      console.log(id+"5555555555");
      getTransformation(id).then(response => {

        this.$router.push({path: "/writeform", query: {id}});

      });
    },
    wordxia3(row){

      const id = row.id;
      getTransformation(id).then(response => {
        this.form = response.data;
        if (this.form.note2 == null || this.form.note2=="") {
          this.$modal.msgError("暂无文件");
        } else {
          const materialsAddress = this.form.note2;
          let fileName = '专利书下载';
          console.log(materialsAddress);
          const xhr = new XMLHttpRequest();
          xhr.open('GET', materialsAddress, true);
          xhr.responseType = 'blob';
          xhr.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36');
          xhr.onload = function () {
            if (xhr.status === 200) {
              const contentType = xhr.response.type;
              const contentDisposition = xhr.getResponseHeader('Content-Disposition');
              let fileName = '';

              if (contentDisposition) {
                const fileNameMatch = contentDisposition.match(/filename="(.*?)"/);
                if (fileNameMatch.length > 1) {
                  fileName = fileNameMatch[1];
                }
              }

              if (!fileName) {
// 如果从响应头中没有解析出文件名，则从 URL 中获取文件名
                const urlSplit = materialsAddress.split('/');
                fileName = urlSplit[urlSplit.length - 1];
              }

              saveAs(xhr.response, fileName);
            } else {
              console.error('文件下载失败');
            }
          };
          xhr.send();
        }
      });

    },
    wordxia1(){
      const materialsAddress = this.form.templatePath;

      const xhr = new XMLHttpRequest();
      xhr.open('GET', materialsAddress, true);
      xhr.responseType = 'blob';
      xhr.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36');
      xhr.onload = function () {
        if (xhr.status === 200) {
          const contentType = xhr.response.type;
          const contentDisposition = xhr.getResponseHeader('Content-Disposition');
          let fileName = '';

          if (contentDisposition) {
            const fileNameMatch = contentDisposition.match(/filename="(.*?)"/);
            if (fileNameMatch.length > 1) {
              fileName = fileNameMatch[1];
            }
          }

          if (!fileName) {
// 如果从响应头中没有解析出文件名，则从 URL 中获取文件名
            const urlSplit = materialsAddress.split('/');
            fileName = urlSplit[urlSplit.length - 1];
          }

          saveAs(xhr.response, fileName);
        } else {
          console.error('文件下载失败');
        }
      };
      xhr.send();
    },
    wordxia2(){
      const materialsAddress = 'http://210.47.178.218/statics/02.研发团队成员及收益分配比例表.docx';

      const xhr = new XMLHttpRequest();
      xhr.open('GET', materialsAddress, true);
      xhr.responseType = 'blob';
      xhr.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36');
      xhr.onload = function () {
        if (xhr.status === 200) {
          const contentType = xhr.response.type;
          const contentDisposition = xhr.getResponseHeader('Content-Disposition');
          let fileName = '';

          if (contentDisposition) {
            const fileNameMatch = contentDisposition.match(/filename="(.*?)"/);
            if (fileNameMatch.length > 1) {
              fileName = fileNameMatch[1];
            }
          }

          if (!fileName) {
// 如果从响应头中没有解析出文件名，则从 URL 中获取文件名
            const urlSplit = materialsAddress.split('/');
            fileName = urlSplit[urlSplit.length - 1];
          }

          saveAs(xhr.response, fileName);
        } else {
          console.error('文件下载失败');
        }
      };
      xhr.send();
    },
    wordxia(row){
      const materialsAddress = row.packetPath;

      const xhr = new XMLHttpRequest();
      xhr.open('GET', materialsAddress, true);
      xhr.responseType = 'blob';
      xhr.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36');
      xhr.onload = function () {
        if (xhr.status === 200) {
          const contentType = xhr.response.type;
          const contentDisposition = xhr.getResponseHeader('Content-Disposition');
          let fileName = '';

          if (contentDisposition) {
            const fileNameMatch = contentDisposition.match(/filename="(.*?)"/);
            if (fileNameMatch.length > 1) {
              fileName = fileNameMatch[1];
            }
          }

          if (!fileName) {
// 如果从响应头中没有解析出文件名，则从 URL 中获取文件名
            const urlSplit = materialsAddress.split('/');
            fileName = urlSplit[urlSplit.length - 1];
          }

          saveAs(xhr.response, fileName);
        } else {
          console.error('文件下载失败');
        }
      };
      xhr.send();
    },
    getNowTime() {
      var now = new Date();
      var year = now.getFullYear(); //得到年份
      var month = now.getMonth(); //得到月份
      var date = now.getDate(); //得到日期
      month = month + 1;
      month = month.toString().padStart(2, "0");
      date = date.toString().padStart(2, "0");
      var defaultDate = `${year}-${month}-${date}`;
      return defaultDate;
    },
    /** 查询成果转化申请列表 */
    getList() {
      this.loading = true;
      listTransformation(this.queryParams).then(response => {
        this.transformationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        acceptTime: null,
        fileId: null,
        transactionPrice: null,
        payArrangement: null,
        commitmentContent: null,
        commitmentTime: null,
        commitmentPhone: null,
        opinionContent: null,
        opinionTime: null,
        applyName: null,
        applyNumber: null,
        applyTime: null,
        auditState: null,
        auditTime: null,
        auditName: null,
        auditNumber: null,
        resultId: null,
        resultName: null,
        resultCategory: null,
        resultIntroduction: null,
        completionUnit: null,
        firstName: null,
        firstCollege: null,
        firstMajor: null,
        firstNumber: null,
        firstPhone: null,
        firstIdnumber: null,
        secondName: null,
        secondCollege: null,
        secondMajor: null,
        secondNumber: null,
        secondPhone: null,
        secondIdnumber: null,
        thirdName: null,
        thirdCollege: null,
        thirdMajor: null,
        thirdNumber: null,
        thirdPhone: null,
        thirdIdnumber: null,
        fourthName: null,
        fourthCollege: null,
        fourthMajor: null,
        fourthNumber: null,
        fourthPhone: null,
        fourthIdnumber: null,
        fifthName: null,
        fifthCollege: null,
        fifthMajor: null,
        fifthNumber: null,
        fifthPhone: null,
        fifthIdnumber: null,
        enterpriseNumber: null,
        enterpriseName: null,
        corporateName: null,
        corporatePhone: null,
        corporateNumber: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加成果转化申请";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getTransformation(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "成果转化申请";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            this.$modal.confirm('是否确认提交，提交后无法修改？').then(function() {
            }).then(() => {
            updateTransformation1(this.form).then(response => {

              this.$modal.msgSuccess("提交成功");
              this.open = false;
              this.getList();
            });
            // } else {
            //
            //     this.$modal.msgError("请添加修改后的文件");
            //
            //  ;
            // }
          })
          }
        }
      });
    },
    // 取消按钮
    chiefCancel() {
      this.chief.open = false;
      this.reset();
    },
    //确定按钮
    chiefForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {

            getshenhe(this.form).then(response => {
              this.$modal.msgSuccess("提交成功");
              this.chief.open = false;
              this.getList();
            });
          }
        }
      });
    },
    handleDetail(row) {
      /*const id = row.id || this.ids
      getLeave(id).then(response => {
        this.form = response.data;
        /!*this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;*!/
        if(this.form.leaveTotalState==1){
          this.form.departmentHeadTime=null;
          this.form.directorGeneralTime=null;
          this.form.politicalCommissarTime=null;
        }
        this.detail.open = true;
        this.detail.title = "请假申请详细";
      });*/
      const id = row.id;
      this.$router.push({ path:"cxcyConversion_detail", query: {id}});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除成果转化申请编号为"' + ids + '"的数据项？').then(function() {
        return delTransformation(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },

    handleView(row) {
      const id = row.id || this.ids

      getTransformation(id).then(response => {



        this.form = response.data;
        this.form.auditNumber=null;
        this.form.auditName=null;
        // /*this.selectedOptions = TextToCode[this.form.leaveAddress.split('/')[0]][this.form.leaveAddress.split('/')[1]].code;*/
         this.form.applyName=this.form.firstName;
           this.form.applyNumber=this.form.firstNumber;
        this.form.applyTime=this.form.applyTime;
         this.form.auditState=null;
         this.form.auditTime=this.getNowTime();
        // this.form.auditNumber=null;
        this.chief.open = true;
        this.chief.title = "审核成果转化申请";
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('project/lystransformation/export', {
        ...this.queryParams
      }, `transformation_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
